﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NetMsSqlLibrary
{
    public class Hanlder
    {
        public SqlConnection con;
        public SqlTransaction Tran;
        public SqlCommand cmd;

        public void HanlderBegin()
        {
            con = SqlManager.GetCon();
            con.Open();
            Tran = con.BeginTransaction();
            cmd = new SqlCommand();
            cmd.Transaction = Tran;
            cmd.Connection = con;
        }

        public void HanlderCommit()
        {
            Tran.Commit();
        }

        public void HanlderRollback()
        {
            Tran.Rollback();
        }

        public void HanlderFinish()
        {
            Tran = null;
            con.Close();
        }
    }
}
